#ifndef MYLEXER_H
#define MYLEXER_H

#include <QObject>
#include <Qsci/qscilexercustom.h>
#include <Qsci/qscistyle.h>

class QSettings;

class MyLexer : public QsciLexerCustom
{
public:
    enum {
        MyStyleDefault = 0,
        MyStyleDark = 1,
        MyStyleLight = 2,
        MaxStyle
    };
    int dataHeight;
    int dataSize;
    int blankLines;
    bool useStyle;
    int line_header_len;
    int row_number_start;
    int row_number_len;

    MyLexer(bool on, int nobg = 8, QString color1 = "#E7F9F0", QString color2 = "#FFFFE1", QObject *parent = nullptr);
    ~MyLexer();
    const char *language() const override;
    QString description(int) const override;
    void styleText(int start, int end) override;
    //    virtual QColor defaultColor(int) const;
    virtual QFont defaultFont(int) const override;
    virtual QColor defaultPaper(int) const override;

    void setIgnoredColumns(int val);
    void setBGColor(QString color1, QString color2);
    void setEnabled(bool on);
    void setIgnoreColumnsOn(bool on);
    void clearStyleMap();

private:
    QsciStyle getStyle(int);

    void styleTextInner(int start, int end);

    QString darkColor;
    QString lightColor;

    QsciStyle darkStyle;
    QsciStyle lightStyle;
    QsciStyle defaultStyle;
    int ignoredColumns;
    bool m_ignoreColumnsOn;
    QMap<QString, bool> lineStyledMap;
    char *chars;
    QSettings *iniconf;
    /*
>>> 1024 * 1024 * 10
10485760
>>> 1920*1028*4
 7895040
    */
    const int chars_len = 1024 * 1024 * 10; // bigger than 1920 * 1080 * 3
};

#endif // MYLEXER_H
